package tjs.org.springloader.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import tjs.org.springLoader.annotion.EnableAutoResetLoader;
import tjs.org.springloader.demo.controller.UserTestController;
import tjs.org.springloader.demo.service.UserService;

@SpringBootApplication
@EnableAutoResetLoader
public class TjsSpringLoaderDemoApplication implements CommandLineRunner {

    @Autowired
    private UserTestController userTestControllerl;
    @Autowired
    private UserService userService;
    @Autowired
    private ApplicationContext applicationContext;

    public static void main(String[] args) {
        SpringApplication.run(TjsSpringLoaderDemoApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        while (true) {
            System.out.println("userService " + userTestControllerl.test1());
            System.out.println("userService " + userService.test1());
            UserService userService2 = (UserService) applicationContext.getBean("userService");
            System.out.println("userService2 " + userService2.test1());
            Thread.sleep(2000);
        }
    }
}
